package org.example.erp.web.handler;
/*
 * @Date 2024-10-27
 * @Author 28254
 * @ClassName MyMetaObjectHandler
 * 用于处理字段的自动填充策略
*/

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.util.Date;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject,"loginTime", Date.class,new Date()); //UserLoginLog实体类中字段
        this.strictInsertFill(metaObject,"createTime", Date.class,new Date()); //Material实体类中字段
        this.strictInsertFill(metaObject,"noticeCreateTime", Date.class,new Date()); //Notice实体类中字段
        this.strictInsertFill(metaObject,"updateTime", Date.class,new Date());
        this.strictInsertFill(metaObject,"loginDate", Date.class,new Date());
    }
    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject,"createTime", Date.class,new Date());
        this.strictInsertFill(metaObject,"updateTime", Date.class,new Date());
        this.strictInsertFill(metaObject,"loginDate", Date.class,new Date());
    }
}
